import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Card {
    public String suit; //花色
    public int rank;  //面值
    public static List<Card> list =new ArrayList<>(52);

    @Override
    public String toString() {
        return "Card{" +"["+suit+","+rank+"]"+" ";
    }

    public void buyCard (){
        int cardNumber=52;
        String[] suits = {"♥","♦","♣","♠"};
        for (int i = 0; i < 4; i++) {
            for (int j = 1; j <= 13; j++) {
                Card card =new Card();
                card.rank=j;
                card.suit=suits[i];
                list.add(card);
            }
        }
    }
    public static void swap(List<Card> ok,int j,int k){
        Card o=ok.get(j);
        ok.set(j,ok.get(k));
        ok.set(k,o);
    }

    public static void shuffle(){
        Random random =new Random();
        for (int i = list.size()-1; i >0 ; i--) {
            int r=random.nextInt(i);
            swap(list,i,r);
        }
    }

}
